package calculator;

import java.util.regex.*;

public class Tokenizer {

    private final String delimiter;
    private final String numbers;

    public Tokenizer(String text) {
        Matcher m = Pattern.compile("\\/\\/(.)\n(.*)").matcher(text);
        if(m.matches()) {
            delimiter=Pattern.quote(m.group(1));
            numbers=m.group(2);
        } else {
            delimiter="(,|\\\n)";
            numbers=text;
        }
    }

    public String[] tokens() {
        return numbers.split(delimiter);
    }

}
